<%@ page import="pojo.Manager" %>
<%@ page import="dao.ManagerDao" %>
<%@ page import="java.util.List" %>
<%@ page import="pojo.Student" %><%--
  Created by IntelliJ IDEA.
  User: konley
  Date: 2020/6/11
  Time: 14:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>校园一卡通管理系统 | 管理端</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/css.css"/>
    <script src="${pageContext.request.contextPath }/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath }/js/jquery-3.4.1.js" type="text/javascript"
            charset="utf-8"></script>
    <style type="text/css">
        body {
            background-image: url("photo/bg.jpg");
        }
    </style>
</head>
<body>
<!--top-->
<div style="background-color:#444;">
    <div class="container">
        <div class="row">
            <h2 style="color: white;font-weight: bold;">校园一卡通系统 | <span style="color: #FF6666;">管理端</span></h2>
        </div>
    </div>
</div>
<div class="container">
    <%
        int moneySum = Integer.parseInt(session.getAttribute("moneySum") + ""); //总收入
        int billSum = Integer.parseInt(session.getAttribute("billSum") + "");   //账单条数
        int stuSum = Integer.parseInt(session.getAttribute("stuSum") + "");    //学生数
        int cardSum = Integer.parseInt(session.getAttribute("cardSum") + "");   //饭卡数
        int managerSum = Integer.parseInt(session.getAttribute("managerSum") + ""); //管理员人数
        int money1 = Integer.parseInt(session.getAttribute("money1Sum") + "");  //一食堂收入
        int money2 = Integer.parseInt(session.getAttribute("money2Sum") + "");  //二食堂收入
        int money3 = Integer.parseInt(session.getAttribute("money3Sum") + "");  //三食堂收入
        Manager manager = (Manager) session.getAttribute("manager");    //管理员信息
        List<Student> studentList = (List<Student>) request.getAttribute("list");   //查询到的学生集合
    %>
    <!--欢迎-->
    <br>
    <div class="row">
        <div class="alert alert-success">欢迎您，<%=manager.getName()%>老师，工号<%=manager.getMid()%>
        </div>
    </div>
    <!--统计信息区-->
    <div class="row">
        <div class="panel panel-info">
            <div class="panel-body">
                <div class="row">
                    <!--数据库统计-->
                    <div class="col-sm-6">
                        <ul class="list-group">
                            <li class="list-group-item">
                                <span class="badge">新</span>
                                <strong>累计总收入金额：</strong>
                                <span style="color: darkred"><%=moneySum%>.00 元</span>
                            </li>
                            <li class="list-group-item"><strong>系统的账单记录：</strong>
                                <span style="color: darkred"><%=billSum%> 条</span></li>
                            <li class="list-group-item"><strong>管理的学生人数：</strong>
                                <span style="color: darkred"><%=stuSum%> 人</span></li>
                            <li class="list-group-item"><strong>管理的校园卡数：</strong>
                                <span style="color: darkred"><%=cardSum%> 张</span></li>
                            <li class="list-group-item"><strong>数据库管理员数：</strong>
                                <span style="color: darkred"><%=managerSum%> 人</span></li>
                        </ul>
                    </div>
                    <!--食堂收入统计!-->
                    <!--占比计算公式：该食堂收入/食堂总收入*100，转为float格式，再格式化为2f-->
                    <!--进度条：width=占比-->
                    <div class="col-sm-6">
                        <h4>一食堂收入<%=money1%>.00元，占比<%=String.format("%.2f", (float) money1 / moneySum * 100)%>%</h4>
                        <div class="progress progress-striped active">
                            <div class="progress-bar progress-bar-success" role="progressbar"
                                 style="width: <%=String.format("%.2f", (float)money1/moneySum*100)%>%;">
                            </div>
                        </div>

                        <h4>二食堂收入<%=money2%>.00元，占比<%=String.format("%.2f", (float) money2 / moneySum * 100)%>%</h4>
                        <div class="progress progress-striped active">
                            <div class="progress-bar progress-bar-info" role="progressbar"
                                 style="width: <%=String.format("%.2f", (float)money2/moneySum*100)%>%;">
                            </div>
                        </div>

                        <h4>三食堂收入<%=money3%>.00元，占比<%=String.format("%.2f", (float) money3 / moneySum * 100)%>%</h4>
                        <div class="progress progress-striped active">
                            <div class="progress-bar progress-bar-striped" role="progressbar"
                                 style="width: <%=String.format("%.2f", (float)money3/moneySum*100)%>%;">
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <div class="panel-footer " style="text-align: right">
                <!--带mid过去，做二次验证-->
                <a href="ManagerServlet?m=toAdd&mid=<%=manager.getMid()%>">
                    <button type="button" class="btn btn-info btn-sm">开通饭卡</button>
                </a>
                &nbsp;&nbsp;
                <a href="QuitServlet">
                    <button type="button" class="btn btn-danger btn-sm">退出登录</button>
                </a>
            </div>
        </div>
    </div>
    <!--查询学生功能-->
    <div class="row">
        <div class="panel panel-danger">
            <br>
            <div class="panel-body">
                <div class="row">
                    <!--搜索区-->
                    <div class="col-sm-6 col-sm-offset-3">
                        <form name="toSearchStu" action="ManagerServlet" method="post" class="form-horizontal"
                              role="form">
                            <div class="form-group">
                                <div class="col-sm-7">
                                    <input name="txt" class="form-control" type="text" placeholder="请输入学号/姓名，默认查所有学生"/>
                                </div>
                                <div class="col-sm-4">
                                    <button type="submit" name="m" value="searchSid" class="btn btn-success">查学号
                                    </button>&nbsp;
                                    <button type="submit" name="m" value="searchName" class="btn btn-primary">查姓名
                                    </button>
                                </div>
                            </div>
                        </form>
                        <br>
                        <%
                            if (studentList != null) { %>
                        <!--显示学生信息-->
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>
                                <td>学号</td>
                                <td>姓名</td>
                                <td>性别</td>
                                <td>系别</td>
                                <td>操作</td>
                            </tr>
                            </thead>
                            <tbody>
                            <% for (Student stu : studentList) { %>
                            <tr>
                                <td><%=stu.getSid()%>
                                </td>
                                <td><%=stu.getName()%>
                                </td>
                                <td><%=stu.getSex()%>
                                </td>
                                <td><%=stu.getDept()%>
                                </td>
                                <td><a href="ManagerServlet?m=searchStuAll&sid=<%=stu.getSid()%>">管理学生</a></td>
                            </tr>
                            <% } %>
                            </tbody>
                        </table>
                        <% } %>
                        <% if (request.getAttribute("stuMsg") != null) { %>
                        <div class="alert alert-danger"><%=request.getAttribute("stuMsg")%>
                        </div>
                        <% } %>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--查询饭卡功能-->
    <div class="row">
        <div class="panel panel-danger">
            <br>
            <div class="panel-body">
                <div class="row">
                    <!--搜索区-->
                    <div class="col-sm-6 col-sm-offset-3">
                        <form name="toSearchStu" action="ManagerServlet" method="post" class="form-horizontal"
                              role="form">
                            <div class="form-group">
                                <div class="col-sm-7">
                                    <input name="cid" class="form-control" type="text" placeholder="请输入准确的饭卡号"/>
                                </div>
                                <div class="col-sm-4">
                                    <button type="submit" name="m" value="searchCid" class="btn btn-success">查饭卡
                                    </button>&nbsp;
                                </div>
                            </div>
                        </form>
                        <br>
                        <% if (request.getAttribute("cardMsg") != null) { %>
                        <div class="alert alert-danger"><%=request.getAttribute("cardMsg")%>
                        </div>
                        <% } %>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
